package com.example.campuslink.commen.db.ai

import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.TypeConverters
import com.example.campuslink.commen.db.DeepSeekTalkBeanConverter
import com.example.campuslink.model.DeepSeekTalkData

@Entity(tableName = "ai_table", primaryKeys = ["id", "userNumber"])
data class AiTable(
    var id: Int = 0,
    var userNumber: String = "",
    @TypeConverters(DeepSeekTalkBeanConverter::class)
    var aiTalkData: MutableList<DeepSeekTalkData>? = null,
    var newAddCount: Int = 0
) {
    @Ignore
    constructor() : this(id = 0, userNumber = "")

    companion object {
        suspend fun insertWithId(
            dao: AiDao,
            aiTable: AiTable
        ) {
            val maxId = dao.getMaxId() ?: 0
            dao.insertAiTable(aiTable.copy(id = maxId + 1))
        }
    }
}
